#author:xxf
#date:2020年7月24日09:47:20

import xlwt
import codecs

#读取文件
f = codecs.open(r'./输入.txt','r',encoding='utf-8')
data = f.readlines()
f.close()

#获取总行数
num = (int)(len(data)/2)

#进行字符串格式化，res为最后结果
index = ['A','B','C','D']
res = []
i = -1
for line in data:
    if line[0]=='A':
        temp = line.split()
        lst = []
        for s in temp:
            if s not in index:
                lst.append(s)
        res[i] = res[i]+lst
        #print(lst)
    elif line[0].isdigit():
        temp = line.strip()
        temp = temp.strip('？')
        temp = temp[2:]
        temp = temp.strip()

        res.append([])
        i+=1
        res[i].append(temp)
        res[i].append('')
        #print(temp)
#print(res)

#写入表格
book = xlwt.Workbook(encoding="utf-8",style_compression=0)
sheetName = ['第一讲','第二讲','第三讲','第四讲','第五讲','第六讲']
for i in range(0,num,10):
    sheet = book.add_sheet(sheetName[int(i/10)%6] if i<60 else sheetName[int(i/10)%6]+str(i),cell_overwrite_ok=True)
    for j in range(i,i+10):
        for k in range(6):
            sheet.write(j-i,k,res[j][k])

book.save("输出.xlsx")
